
%**** Prod Tauchen_prob (adapted directly from the Gauss version)
% GLB 2020

function p_trans = tauchen_prob(mu,rho_eps,sig_eps,grid)

%local N, g_eps, i, z_eps, p_trans, j, x_mean;

grid=grid';

N=size(grid,1);
x_mean=(grid(1:N-1)+grid(2:N))/2;

p_trans = normcdf((repmat(x_mean',N,1)-rho_eps*repmat(grid,1,N-1)-mu)/sig_eps,0,1);

p_trans(:,2:end) = p_trans(:,2:end) - p_trans(:,1:end-1);

% Create probability of going to the last state as complement of all the
% other probabilities
p_trans(:,N)=ones(N,1)-sum(p_trans,2);

